package com.scs.application.modules.wm.utils;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.scs.application.modules.wm.entity.Stock;
import com.scs.application.modules.wm.service.StockLockService;
import com.scs.application.modules.wm.service.StockService;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import java.util.List;
import java.util.Map;

/**
 * @ Description： 库存相关公共 服务方法
 */
@Slf4j
@Component
public class StockCommonService {
    private static final Logger logger = LoggerFactory.getLogger(StockCommonService.class);
    @Autowired
    StockService stockService;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Autowired
    StockLockService stockLockService;
    private static StockCommonService services;

    @PostConstruct
    public void init() {
        services = this;
        services.stockService = this.stockService;
        services.jdbcTemplate = this.jdbcTemplate;
        services.stockLockService = this.stockLockService;
    }

    /**
     * @Description：   查询库存，同时也查询0库存表，一般用于科室退货、供应商退货、his退费、科室冲红等反向添加库存业务
     * @param  queryWrapper        查询条件
     * @param userParam             特殊条件，预留
     */
    public static List<Stock> listStockWithZero(QueryWrapper queryWrapper, Map<String,Object> userParam){
        return services.stockService.listStockWithZero(queryWrapper,null);
    }
}
